﻿function openPopup(path, name, width, height) {
	var left = (screen.width - width) / 2 ; 
	var top = (screen.height - height) / 2; 
	return window.open(path, name, "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",menubar=no,toolbar=no,modal=yes,dependent=yes");
}

function closeWindow(isPrompt) {
	var toClose = true;
	if (isPrompt)
		toClose = confirm('창을 닫을까요?');
	
	if (toClose) {
		window.open('', '_self', '');
		window.close();
	}
}

function trim(str) {
    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function deg2rad (angle) {
	return (angle/180)*Math.PI;
}
function rad2deg (angle) {
    return (angle/Math.PI) * 180;
}
function distance(lat1, lon1, lat2, lon2) { 
	theta = lon1 - lon2 ; 
	dist = Math.sin ( deg2rad ( lat1 )) * Math.sin ( deg2rad ( lat2 )) + Math.cos ( deg2rad ( lat1 )) * Math.cos ( deg2rad ( lat2 )) * Math.cos ( deg2rad ( theta )); 
	dist = Math.acos ( dist ); 
	dist = rad2deg ( dist ); 
	miles = dist * 60 * 1.1515 ;
	
	return (miles * 1609.344); 
}

function printNow() {
	var curTime = new Date();
	return curTime.getFullYear() + '-' + (curTime.getMonth()+1) + '-' + curTime.getDate() + ' ' + curTime.getHours() + ':' + curTime.getMinutes() + ':' + curTime.getSeconds();
}
function printNowDate() {
	var curTime = new Date();
	return curTime.getFullYear() + '-' + (curTime.getMonth()+1) + '-' + curTime.getDate();
}